{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">会员卡类型</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
        <script type="text/html" id="barTool">
            <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("desc_list")}?id={{ d.id }}' data-title="详情编辑"
               data-full="true">详情编辑</a>

            <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("mcard_list")}?id={{ d.id }}' data-title="会员卡列表"
               data-full="true">会员卡列表</a>

            <a class="layui-btn layui-btn-xs layui-btn-warm" data-open='{:url("server_list")}?id={{ d.id }}' data-title="服务管理"
               data-full="true">服务管理</a>

            <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="编辑内容"
               data-full="true">编辑</a>
            <a href='{:url("del")}?ids={{ d.id }}'
               class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
        </script>

        <script type="text/html" id="statusTypeTpl">
            <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
        </script>

        <script type="text/html" id="picTpl">

            <img style="max-width:80px; max-height:30px;" src="{{d.img}}" data-image="{{d.name}}">

        </script>

    </div>
</div>
{/block}
{block name="script"}
<script>
layui.use('yznTable', function() {
    var table = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        add_url: "{:url('add')}",
        edit_url: "{:url('edit')}",
        delete_url: "{:url('del')}",
    };

    table.render({
        init: init,
        id: 'currentTable',
        elem: '#currentTable',
        url: '{:url("index")}',
        toolbar: ['refresh', [{
            text: '添加',
            url: init.add_url,
            method: 'open',
            icon: 'iconfont icon-add',
            class: 'layui-btn layui-btn-normal layui-btn-sm',
            // extend: 'data-full="true"',
        }]],
        cols: [
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'id', align: "center", width: '4%', title: 'ID' },
                { field: 'name', align: "center", width: '15%', title: '类型名称'},
                { field: 'discount', align: "center", width: '15%', title: '折扣%'},
                { field: 'day_num', align: "center", width: '10%', title: '会员天数'},
                { field: 'count1', align: "center", width: '10%', title: '已激活数量'},
                { field: 'count', align: "center", width: '10%', title: '总数'},
                {field: 'sort', align: "center", width: '15%', title: '排序', search: false},
                { field: 'status', width: '15%', align: "center", title: '状态', templet: '#statusTypeTpl', unresize: true, selectList: { 0: '隐藏', 1: '显示' } },
                {fixed: 'right', align: 'center',width: '30%', title: '操作', toolbar: '#barTool'}
            ]
        ],
        page: {}
    });
    yznTable.bindevent();
});
</script>
{/block}